index_num = 0

for dir_link in chapter_list:
	file_name = str(index_num) + '.txt'
	file_name = os.path.join(file_path, file_name)
	f = open(file_name, 'w')
	
	f.write(dir_link.xpath('text()')[0].encode('utf-8'))
	f.write('\n')
	
	content_url = dir_link.xpath('@href')[0]
	content_list = get_content(url_path, content_url)
	
	for content in content_list:
		f.write(content.encode('utf-8'))
	f.write('\n')
	
f.close()